#ifndef UILIB_H
#define UILIB_H
//保存各种控件信息
#include<QMap>
#include "eventcenter.h"
#include <QColor>
#include <QFont>
//控件锚点

enum ANCHOR
{
    LEFT_TOP,
    LEFT_BOTTOM,
    RIGHT_TOP,
    RIGHT_BOTTOM,
    CENTER
};

//窗口布局
enum LAYOUT
{
    NONE_LAYOUT,
    VERTICAL,
    HORIZONTAL,
};

struct ButtonInfo
{
    QString name;
    bool interactive = true;
    QString soundPath;
    QString img = ":/res/UI/button.png";
    QString inImg = ":/res/UI/button.png";
    QString pressImg = ":/res/UI/button.png";
    //事件
    BUTTONEVENT event = NONE;
    //关闭/打开的界面的名字
    QString eventWidgetName;
    QString text;
    QFont font = QFont("宋体",20);
    //字体颜色
    QColor color = QColor("black");
    ButtonInfo(QString sound_path = "",QString img_ = ":/res/UI/button.png",QString in_img =
            ":/res/UI/button.png",QString press_img = ":/res/UI/button.png"){
        soundPath = sound_path;
        img = img_;
        inImg = in_img;
        pressImg = press_img;
    };
};

struct LabelInfo
{
    QString name;
    QString img;
    QString text;
    QColor color = QColor("white");
    LabelInfo(QString name_ = "",QString img_ = ":/res/UI/dialog.png",QString text_ = "容器")
    {
        name = name_;
        img = img_;
        text = text_;
    };
};

class UILib
{
public:
    UILib(const UILib&) = delete;
    UILib& operator=(const UILib&) = delete;
    static UILib& Instance();
    ~UILib();
    QMap<QString,LabelInfo*> labels;
    QMap<QString,ButtonInfo*> btns;
    //只能编辑部件外观的特殊UI
    QVector<QString> widgetWhiteList =
    {
        "游戏",
        "图鉴",
        "存档",
        "数值",
        "封面",
        "菜单",
    };
    QVector<QString> btnWhiteList =
    {
        "菜单按钮",
        "选项",
        "返回主页",
        "返回游戏",
        "退出游戏",
        "图鉴-上一张",
        "图鉴-下一张",
        "存档-删除存档",
        "菜单-查看图鉴",
        "菜单-查看数值",
        "菜单-语音",
        "菜单-音乐",
        "菜单-音效",
        "封面-开始游戏"
    };
    QVector<QString> labelWhiteList =
    {
        "游戏-角色名",
        "游戏-对话框",
        "存档-存档框",
        "图鉴-容器",
        "存档-容器",
        "数值-容器",
        "数值-数值框",
        "存档-添加存档"
    };
    QMap<QString,ANCHOR> anchorMap =
    {
        {"左上角",LEFT_TOP},
        {"左下角",LEFT_BOTTOM},
        {"右上角",RIGHT_TOP},
        {"右下角",RIGHT_BOTTOM},
        {"画面中心",CENTER}
    };
    QMap<QString,LAYOUT> layoutMap =
    {
        {"无",NONE_LAYOUT},
        {"垂直排列",VERTICAL},
        {"水平排列",HORIZONTAL}
    };
private:
    UILib();
};

#endif // UILIB_H
